// tslint:disable-next-line:ordered-imports
import op from '@dfeidao/atom-nodejs/db/operate';
import doc_code from '@dfeidao/atom-nodejs/msg/doc-code';
import { IncomingHttpHeaders } from 'http';
import { productid, systemid } from '../../atom/config';
interface Message {
	filter: {
		risk_type: string
		risk_content: string
		risk_status: string
		project_no: string
		project_name: string
		create_time: string
		staff_no: string
		productid: string
		staff_name: string
		involved_amount: string
		memo: string
	};
}
// cookie: {
// 	uk: string;
// 	[key: string]: string
// };
// urls: {
// 	base: string;
// 	origin: string;
// 	url: string;
// };
// query: {};
// params: {};
// headers: {};
// captcha: string;


// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string[];
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const r = await doc_code(action_id, session_id, systemid, 'BM0016508', '', 1);
	const {exec,insert} = op(action_id, session_id, systemid);
	insert('risk_management', {
		productid,
		risk_no: r.result,
		risk_content: message.filter.risk_content,
		risk_status: message.filter.risk_status,
		project_no: message.filter.project_no,
		project_name: message.filter.project_name,
		create_time: message.filter.create_time,
		record_no: message.filter.staff_no,
		recorder_name: message.filter.staff_name,
		risk_type: message.filter.risk_type,
		involved_amount: message.filter.involved_amount,
		memo: message.filter.memo
	});
	const res = await exec();
	return res;
}
